package com.fzz.learnitservice.pojo.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ChatRoleEnum implements BaseEnum{

    USER(1, "用户"),
    ASSISTANT(2, "助手");

    @EnumValue
    private final int code;
    private final String desc;

    public static ChatRoleEnum fromCode(Integer code) {
        if(code == null) return USER;  // 默认用户
        for (ChatRoleEnum e : values()) {
            if (e.getCode() == code) return e;
        }
        return USER;
    }
}
